package com.sihan.swvp.action.rw;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sihan.swvp.action.BaseAction;
import com.sihan.swvp.common.CommonUtil;
import com.sihan.swvp.service.rw.RwcxService;

@Controller
@RequestMapping("/tsk")
public class RwcxAction extends BaseAction{

	@Autowired
	private RwcxService rwcxService;
	
	@ResponseBody
	@RequestMapping("/rw")
	public Object getJcBz(@Param("starttime")String starttime,@Param("endtime")String endtime,@Param("date")String date,String sbid){
		Map<String, Object> params=new HashMap<String, Object>();
		params.put("starttime", starttime);
		params.put("endtime", endtime);
		params.put("date", date);
		params.put("sbid", sbid);
		List<Map<String, Object>> list=rwcxService.getrw(params);
		if(list.isEmpty() && !CommonUtil.isEmptyString(sbid)){
			params.remove("sbid");
			list=rwcxService.getrw(params);
		}
		for (Map<String, Object> map : list) {
			Object sbs = map.get("sbid");
			if(!CommonUtil.isEmptyString(sbs)){
				map.put("sbid", String.valueOf(sbs).split(","));
			}
		}
		return list;
	}
	
	@ResponseBody
	@RequestMapping("/js")
	public Object getJcBzjs(@Param("bzid")Integer bzid){
		Map<String, Object> param=new HashMap<String, Object>();
		param.put("bzid", bzid);
		return rwcxService.getjs(param);
	}
	
	@ResponseBody
	@RequestMapping("/gc")
	public Object getJcbzzyZygc(@Param("jsid")Integer jsid){
		Map<String, Object> param=new HashMap<String, Object>();
		param.put("jsid", jsid);
		return rwcxService.getgc(param);
	}
}
